<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Struct template us_dst_trait</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../date_time/doxy.html#doxygen.date_time_reference.local__timezone__defs_8hpp" title="Header &lt;boost/date_time/local_timezone_defs.hpp&gt;">
<link rel="prev" href="structboost_1_1date__time_1_1uk__dst__trait.html" title="Struct template uk_dst_trait">
<link rel="next" href="classboost_1_1date__time_1_1microsec__clock.html" title="Class template microsec_clock">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="structboost_1_1date__time_1_1uk__dst__trait.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#doxygen.date_time_reference.local__timezone__defs_8hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="classboost_1_1date__time_1_1microsec__clock.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Struct template us_dst_trait</span></h2>
<p>boost::date_time::us_dst_trait — Specification for daylight savings start rules in US. </p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../date_time/doxy.html#doxygen.date_time_reference.local__timezone__defs_8hpp" title="Header &lt;boost/date_time/local_timezone_defs.hpp&gt;">boost/date_time/local_timezone_defs.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> date_type<span class="special">&gt;</span> 
<span class="keyword">struct</span> <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html" title="Struct template us_dst_trait">us_dst_trait</a> <span class="special">{</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">date_type</span><span class="special">::</span><span class="identifier">day_of_week_type</span>                 <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1af27f7596a2b6a17f6dbe232e84ece1b4"></a><span class="identifier">day_of_week_type</span><span class="special">;</span>          
  <span class="keyword">typedef</span> <span class="identifier">date_type</span><span class="special">::</span><span class="identifier">month_type</span>                       <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a48dcdf6deb4ab0cb4b48be4dbcbf6d54"></a><span class="identifier">month_type</span><span class="special">;</span>                
  <span class="keyword">typedef</span> <span class="identifier">date_type</span><span class="special">::</span><span class="identifier">year_type</span>                        <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a7dc2bb744816b71a7e95f56384de54c0"></a><span class="identifier">year_type</span><span class="special">;</span>                 
  <span class="keyword">typedef</span> <a class="link" href="classboost_1_1date__time_1_1nth__kday__of__month.html" title="Class template nth_kday_of_month">date_time::nth_kday_of_month</a><span class="special">&lt;</span> <span class="identifier">date_type</span> <span class="special">&gt;</span>   <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a2e23d03eeda84aaa595c15feca7f0485"></a><span class="identifier">start_rule_functor</span><span class="special">;</span>        
  <span class="keyword">typedef</span> <a class="link" href="classboost_1_1date__time_1_1first__kday__of__month.html" title="Class template first_kday_of_month">date_time::first_kday_of_month</a><span class="special">&lt;</span> <span class="identifier">date_type</span> <span class="special">&gt;</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a182c8481ddf0e08f309467a8b0acf585"></a><span class="identifier">end_rule_functor</span><span class="special">;</span>          
  <span class="keyword">typedef</span> <a class="link" href="classboost_1_1date__time_1_1first__kday__of__month.html" title="Class template first_kday_of_month">date_time::first_kday_of_month</a><span class="special">&lt;</span> <span class="identifier">date_type</span> <span class="special">&gt;</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a04083ccdec081224f6a1322703588841"></a><span class="identifier">start_rule_functor_pre2007</span><span class="special">;</span>
  <span class="keyword">typedef</span> <a class="link" href="classboost_1_1date__time_1_1last__kday__of__month.html" title="Class template last_kday_of_month">date_time::last_kday_of_month</a><span class="special">&lt;</span> <span class="identifier">date_type</span> <span class="special">&gt;</span>  <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1ae962606afffb884b050179d205ae9575"></a><span class="identifier">end_rule_functor_pre2007</span><span class="special">;</span>  

  <span class="comment">// <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html#id-1_3_11_15_3_32_1_1_4_11-bb">public static functions</a></span>
  <span class="keyword">static</span> <span class="identifier">day_of_week_type</span> <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html#doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a77d6ed0750a3acfa702a00b73bc67b2b"><span class="identifier">start_day</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="identifier">month_type</span> <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html#doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a5f8fa4cf82b19933bf99ec1ee093e4c1"><span class="identifier">start_month</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="identifier">day_of_week_type</span> <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html#doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1ab3c2413aae2aa3c77e074344721f012c"><span class="identifier">end_day</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="identifier">month_type</span> <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html#doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1acfc84e2dca90c5d3d0341820214e50ad"><span class="identifier">end_month</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="identifier">date_type</span> <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html#doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a6db5941e421137e02dd516ecca4b3834"><span class="identifier">local_dst_start_day</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="identifier">date_type</span> <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html#doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1addeed7f1a5a64b50f60d901457064a17"><span class="identifier">local_dst_end_day</span></a><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="keyword">int</span> <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html#doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1ae449106ca8f694e24d6049403e571066"><span class="identifier">dst_start_offset_minutes</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="keyword">int</span> <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html#doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a18d0af1255df822e668c90f9f91a17f0"><span class="identifier">dst_end_offset_minutes</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">static</span> <span class="keyword">int</span> <a class="link" href="structboost_1_1date__time_1_1us__dst__trait.html#doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a45af43919a0834bb269ea88a3a30a101"><span class="identifier">dst_shift_length_minutes</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.11.15.3.32.6.4"></a><h2>Description</h2>
<p>This class is used to configure <a class="link" href="classboost_1_1date__time_1_1dst__calc__engine.html" title="Class template dst_calc_engine">dst_calc_engine</a> template typically as follows: </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">gregorian</span><span class="special">;</span>
<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">posix_time</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">us_dst_trait</span><span class="special">&lt;</span><span class="identifier">date</span><span class="special">&gt;</span> <span class="identifier">us_dst_traits</span><span class="special">;</span>
<span class="keyword">typedef</span> <a class="link" href="classboost_1_1date__time_1_1dst__calc__engine.html" title="Class template dst_calc_engine"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">date_time</span><span class="special">::</span><span class="identifier">dst_calc_engine</span></a><span class="special">&lt;</span><span class="identifier">date</span><span class="special">,</span> <span class="identifier">time_duration</span><span class="special">,</span> 
                                          <span class="identifier">us_dst_traits</span><span class="special">&gt;</span>  
                                          <span class="identifier">us_dst_calc</span><span class="special">;</span>
<span class="comment">//calculate the 2002 transition day of USA April 7 2002</span>
<span class="identifier">date</span> <span class="identifier">dst_start</span> <span class="special">=</span> <span class="identifier">us_dst_calc</span><span class="special">::</span><span class="identifier">local_dst_start_day</span><span class="special">(</span><span class="number">2002</span><span class="special">)</span><span class="special">;</span> 

<span class="comment">//calculate the 2002 transition day of USA Oct 27 2002</span>
<span class="identifier">date</span> <span class="identifier">dst_end</span> <span class="special">=</span> <span class="identifier">us_dst_calc</span><span class="special">::</span><span class="identifier">local_dst_end_day</span><span class="special">(</span><span class="number">2002</span><span class="special">)</span><span class="special">;</span> 
                                          
<span class="comment">//check if a local time is in dst or not -- posible answers</span>
<span class="comment">//are yes, no, invalid time label, ambiguous</span>
<span class="identifier">ptime</span> <span class="identifier">t</span><span class="special">(</span><span class="special">...</span><span class="identifier">some</span> <span class="identifier">time</span><span class="special">...</span><span class="special">)</span><span class="special">;</span>  
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">us_dst</span><span class="special">::</span><span class="identifier">local_is_dst</span><span class="special">(</span><span class="identifier">t</span><span class="special">.</span><span class="identifier">date</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">t</span><span class="special">.</span><span class="identifier">time_of_day</span><span class="special">(</span><span class="special">)</span><span class="special">)</span> 
    <span class="special">==</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">date_time</span><span class="special">::</span><span class="identifier">is_not_in_dst</span><span class="special">)</span> 
<span class="special">{</span>

<span class="special">}</span>
</pre>
<p> This generates a type suitable for the calculation of dst transitions for the United States. Of course other templates can be used for other locales. </p>
<div class="refsect2">
<a name="id-1.3.11.15.3.32.6.4.3"></a><h3>
<a name="id-1_3_11_15_3_32_1_1_4_11-bb"></a><code class="computeroutput">us_dst_trait</code> public static functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">day_of_week_type</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a77d6ed0750a3acfa702a00b73bc67b2b"></a><span class="identifier">start_day</span><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">month_type</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a5f8fa4cf82b19933bf99ec1ee093e4c1"></a><span class="identifier">start_month</span><span class="special">(</span><span class="identifier">year_type</span> y<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">day_of_week_type</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1ab3c2413aae2aa3c77e074344721f012c"></a><span class="identifier">end_day</span><span class="special">(</span><span class="identifier">year_type</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">month_type</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1acfc84e2dca90c5d3d0341820214e50ad"></a><span class="identifier">end_month</span><span class="special">(</span><span class="identifier">year_type</span> y<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">date_type</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a6db5941e421137e02dd516ecca4b3834"></a><span class="identifier">local_dst_start_day</span><span class="special">(</span><span class="identifier">year_type</span> year<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="identifier">date_type</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1addeed7f1a5a64b50f60d901457064a17"></a><span class="identifier">local_dst_end_day</span><span class="special">(</span><span class="identifier">year_type</span> year<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="keyword">int</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1ae449106ca8f694e24d6049403e571066"></a><span class="identifier">dst_start_offset_minutes</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="keyword">int</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a18d0af1255df822e668c90f9f91a17f0"></a><span class="identifier">dst_end_offset_minutes</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">static</span> <span class="keyword">int</span> <a name="doxygen.date_time_reference.structboost_1_1date__time_1_1us__dst__trait_1a45af43919a0834bb269ea88a3a30a101"></a><span class="identifier">dst_shift_length_minutes</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
</ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
    <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="structboost_1_1date__time_1_1uk__dst__trait.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time/doxy.html#doxygen.date_time_reference.local__timezone__defs_8hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="classboost_1_1date__time_1_1microsec__clock.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
